home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * NOFSettings.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
- if (!IS.isModuleInitialized("IS.NOF.NOFSettings"))
- {
-
- /****h* NOF_JavaScript_Library/NOF.NOFSettings
- *
- * NAME
- * NOF.NOFSettings
- *
- * DESCRIPTION
- * Encapsulates Fusion NOFSettings operations
- *
- * Sample of use:
- * var regEditObj = new NOF.NOFSettings();
- * var regBaseStr = regEditObj.getRegistryBase();
- * var versionStr = regEditObj.get("Version", NOF.NOFSettings.STRING_VALUE);
- * try {
- * var prevVersion = regEditObj.put("Version", "7.51.0000.5005");
- * } catch (e) {
- * alert( "error: "+e );
- * }
- *
- * External dependencies: NOF.UTIL.Exception
- ****/
-
- /**
- * Constructor
- */
- function NOF_NOFSettings( ) {
- this.__proto__ = NOF_NOFSettings.prototype;
- this.CLASS_NAME = "NOFSettings";
- }
- {
- var member = NOF_NOFSettings.prototype;
- member.HKEY_LOCAL_MACHINE = true;
-
- var method = NOF_NOFSettings.prototype;
-
- /**
- * getRegistryBase
- * @return the string defining the registry base key for the Fusion installation.
- **/
- method.getRegistryBase = function () {
- return NOF.App.getFSIApp().GetRegistryBase();
- }
-
- /**
- * get
- * @param key - the registry key to search for. It can specify
- * a subfolder in the registry using backslash as delimiter.
- * The key is relative to the registry base key for Fusion.
- * @param type - type of the value specified by the key param. (NOF.NOFSettings.INT_VALUE or NOF.NOFSettings.STRING_VALUE)
- * @return the registry value (as string or int) or null if the key does not exist
- **/
- method.get = function ( key, type, notInLocalReg ) {
- var ret = null;
- var localMachine = this.HKEY_LOCAL_MACHINE;
- if (notInLocalReg == true) {
- localMachine = !this.HKEY_LOCAL_MACHINE;
- }
- if (type == NOF.NOFSettings.INT_VALUE) {
- ret = NOF.App.getFSIApp().GetRegistryInt(localMachine, key);
- if (ret == 0) {
- ret = null;
- }
- } else if (type == NOF.NOFSettings.STRING_VALUE) {
- ret = NOF.App.getFSIApp().GetRegistryString(localMachine, key);
- if ((ret != null) && (ret.length == 0)) {
- ret = null;
- }
- }
- /*
- if ((ret == null) && (notInLocalReg != true)) {
- return this.get(key, type, true);
- }
- */
- return ret;
- }
-
- /**
- * put
- * @param key - the registry key whose value has to be modified. It can specify
- * a subfolder in the registry using backslash as delimiter.
- * The key is relative to the registry base key for Fusion.
- * @param value - new value
- * @return previous value associated with specified key.
- * @throws a NOF.UTIL.Exception if the key does not exist or the value is read only
- **/
- method.put = function ( key, value ) {
- var ret = null;
- var backslashIndex = key.lastIndexOf("\\");
- if ( backslashIndex > -1 ) {
- key = key.substring( backslashIndex + 1, key.length );
- }
-
- try {
- eval("ret = NOF.App.getFSIApp()."+key);
- if ( (ret != null) && (ret != 'undefined') ) {
- eval("NOF.App.getFSIApp()."+key+" = value");
- } else {
- // maybe is a FSIApp2 member
- eval("ret = NOF.App.getFSIApp2()."+key);
- if ( (ret != null) && (ret != 'undefined') ) {
- eval("NOF.App.getFSIApp2()."+key+" = value");
- }
- }
- if ( ''+ret == 'undefined' ) {
- throw ( new NOF.UTIL.Exception("IllegalWrite") );
- }
-
- return ret;
-
- } catch(e) {
- //throw new NOF.IllegalWriteException(e.description);
- throw (new NOF.UTIL.Exception("IllegalWrite " + e.description));
- }
- }
-
- /**
- * keys
- * @param pPath - the registry folder (relative to the Fusion key) to search for.
- * @return an Array object containing the keys found.
- */
- method.keys = function ( pPath ) {
- return this.search( pPath, true);
- }
-
- /**
- * values
- * @param pPath - the registry folder (relative to the Fusion key) to search for.
- * @return an Array object containing the values corresponding to the keys found in pPath registry.
- */
- method.values = function ( pPath ) {
- return this.search( pPath, false);
- }
-
- /**
- * search
- **/
- method.search = function ( pPath, pKeys) {
- var ret = new Array();
- var regIterator = new ActiveXObject(NOF.ProgId.FSIRegIterator);
- regIterator.DefineSearch( this.HKEY_LOCAL_MACHINE, pPath, pKeys);
- var tmp = "";
- while (true) {
- tmp = regIterator.GetNext();
- if (tmp.length == 0)
- break;
- ret[ret.length] = tmp;
- }
- regIterator = null;
- return ret;
- }
- /*
- method.getApp = function () {
- return NOF.App.getFSIApp();
- }
-
- method.getApp2 = function () {
- return NOF.App.getFSIApp2();
- }
- */
- }
-
- NOF.__proto__.NOFSettings = NOF_NOFSettings;
-
- NOF.addVariable("NOFSettings.INT_VALUE", "Integer");
- NOF.addVariable("NOFSettings.STRING_VALUE", "String");
- }